﻿/*-------------------------------------------------------------------------
* 命名空间: SiliconSelect.Models/DetectTypeModel
* 类       名: DetectTypeModel
* 功      能:  TD
* 时      间:  2023/6/29 17:58:25
* 版      本:  V1.0
* 作      者:  Fioman
* 格      言:  Talk is cheap,show me the code ^_^
*-------------------------------------------------------------------------*/
using SiliconSelect.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;

namespace SiliconSelect.Models
{
    public class DetectTypeModel : NotifyBase
    {
        /// <summary>
        /// 统计的计数的对应的Index的下标,这个下标是和Level挂钩的.
        /// </summary>
        private int _levelIndex;

        public int LevelIndex
        {
            get { return _levelIndex; }
            set { SetProperty(ref _levelIndex, value); }
        }

        /// <summary>
        /// 统计晶棒信息的检测类型
        /// </summary>
        private string? _detectedType;

        public string? DetectedType
        {
            get { return _detectedType; }
            set { SetProperty(ref _detectedType, value); }
        }

        /// <summary>
        /// 统计晶棒信息的检测个数
        /// </summary>
        private string? _detectedCount;

        public string? DetectedCount
        {
            get
            {
                return _detectedCount;
            }
            set
            {
                SetProperty(ref _detectedCount, value);
                if (GlobalValues.DetectedTypeNamesDefineSelf.ContainsKey(LevelIndex))
                {
                    if (LevelIndex == 38)
                    {
                        GlobalValues.TotalWaferCount = int.Parse(value!);
                    }
                }
                double percent;
                if (GlobalValues.TotalWaferCount != 0)
                {
                    double a = double.Parse(DetectedCount!);
                    percent = a / (double)GlobalValues.TotalWaferCount * 100;
                }
                else
                {
                    percent = 0.0;
                }
                DetectedCountInfo = $"{DetectedCount} ({percent.ToString("f2")}%)";
            }
        }

        /// <summary>
        /// 界面上显示的统计信息,带上百分号,这样更直接一些
        /// </summary>
        private string? _detectedCountInfo;

        public string? DetectedCountInfo
        {
            get { return _detectedCountInfo; }
            set { SetProperty(ref _detectedCountInfo, value); }
        }

    }
}
